<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
    <div class="table-box">
        <table>
        <tbody>
        <tr>
        <td>姓名</td>
        <td></td>
         <td>单位</td>
          <td></td>
          <td>入职时间</td>
          <td></td>
        </tr>
        <tr>
        <td rowspan="3">原岗位</td>
        <td>部门</td>
        <td></td>
        <td>职务</td>
        <td colspan="2"></td>
        </tr>
         <tr>
         <td>主要工作内容</td>
         <td colspan="4"></td>
          </tr>
           <tr>
              <td>薪酬待遇</td>
              <td colspan="4"></td>
            </tr>
            <tr>
            <td rowspan="6">变更后岗位</td>
            <td >部门</td>
            <td ></td>
             <td>岗位</td>
              <td colspan="2"></td>
            </tr>
            <tr>
            <td>主要工作内容</td>
            <td colspan="4"></td>
            </tr>
            <tr>
            <td rowspan="4">薪酬待遇</td>
            <td >基本工资</td>
            <td >交通补贴</td>
            <td >通讯费</td>
            <td ></td>
            </tr>
            <tr>
            <td ></td>
            <td ></td>
            <td ></td>
            <td ></td>
            </tr>
             <tr>
              <td >生活补贴</td>
              <td >房补</td>
              <td >工龄津贴</td>
              <td ></td>
              </tr>
              <tr>
              <td ></td>
              <td ></td>
              <td ></td>
              <td ></td>
              </tr>
               <tr>
               <td rowspan="6">变更后岗位</td>
                          <td >部门</td>
                          <td ></td>
                           <td>岗位</td>
                            <td colspan="2"></td>
                          </tr>
                          <tr>
                          <td>主要工作内容</td>
                          <td colspan="4"></td>
                          </tr>
                          <tr>
                          <td rowspan="2">薪酬待遇</td>
                          <td >基本工资</td>
                          <td >交通补贴</td>
                          <td >通讯费</td>
                          <td ></td>
                          </tr>
                          <tr>
                          <td ></td>
                          <td ></td>
                          <td ></td>
                          <td ></td>
                          </tr>
                           <tr>
                           <td rowspan="2">社会保险变更情况</td>
                            <td >养老保险</td>
                            <td >失业保险</td>
                            <td >医疗保险</td>
                            <td ></td>
                            </tr>
                            <tr>
                            <td ></td>
                            <td ></td>
                            <td ></td>
                            <td ></td>
                            </tr>
                            </tr>
           <tr>
             <td >变更原因</td>
             <td colspan="5"></td>
           </tr>
           <tr>
            <td colspan="6">此职务变更自          年       月       日起生效</td>
          </tr>
        </tbody>
        </table>
      </div>
    </a-spin>
  </j-modal>
</template>

<script>

  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import { validateDuplicateValue } from '@/utils/util'
  import JDate from '@/components/jeecg/JDate'  


  export default {
    name: "BjGwbdModal",
    components: { 
      JDate,
    },
    data () {
      return {
        form: this.$form.createForm(this),
        title:"操作",
        width:800,
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/bj/bjGwbd/add",
          edit: "/bj/bjGwbd/edit",
        }
      }
    },
    created () {
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model,'name','danwei','ruzhidt','oldbm','oldzw','oldmain','oldbasic','newbm','newgw','newmain','newjbgz','jiaotongbutie','tongxunfei','shbt','fangbu','gljt','gwgz','fdgz','yldaijiao','yldaijiaoje','shiyedaijiao','shiyedaijiaoje','yiliaodaijiao','yiliaodaijiaoje','bgyuanyin','sxdt','createBy','createTime','updateBy','updateTime'))
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            console.log("表单提交数据",formData)
            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }
         
        })
      },
      handleCancel () {
        this.close()
      },
      popupCallback(row){
        this.form.setFieldsValue(pick(row,'name','danwei','ruzhidt','oldbm','oldzw','oldmain','oldbasic','newbm','newgw','newmain','newjbgz','jiaotongbutie','tongxunfei','shbt','fangbu','gljt','gwgz','fdgz','yldaijiao','yldaijiaoje','shiyedaijiao','shiyedaijiaoje','yiliaodaijiao','yiliaodaijiaoje','bgyuanyin','sxdt','createBy','createTime','updateBy','updateTime'))
      },

      
    }
  }
</script>
<style>
.table-box table{
width:100%
}
.table-box tr td{
border:solid 1px #ccc;
padding:10px;
}
</style>
